package com.hyj.boxueguxiangmu.fragment;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import com.hyj.boxueguxiangmu.R;
import com.hyj.boxueguxiangmu.activity.LongActivity;

/**
 * Created by Administrator on 2018/4/2.
 */

public class MyFragment extends Fragment {
    ImageView imageView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fragment_my,container,false);
        imageView = view.findViewById(R.id.img);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.i("MyFragment","login");
                SharedPreferences sp = getActivity().getSharedPreferences("login", Context.MODE_PRIVATE);
                boolean islogin = sp .getBoolean("islogin",false);
                if (islogin){
                    Toast.makeText(getActivity(),"已经登录过了",Toast.LENGTH_LONG).show();
                    return;
                }
                Intent intent = new Intent(getActivity(), LongActivity.class);
                startActivity(intent);
            }
        });
        return view;
    }
    public void login(View  view){Log.i("MyFragment","login");}

}
